<template>
	<div id="appRoot">
		<sidebar>
			<card label="入库审核">
			</card>
			<div class="table-container" v-loading.body="loading">
				<template v-if="tableDataError">
					<table-data-fail type="error"></table-data-fail>
				</template>
				<template v-else-if="tableData.length > 0">
					<el-table
							:data="tableData"
							stripe
							border
							style="width: 100%">
						<el-table-column
								align="center"
								header-align="left"
								label="文档标题">
							<template scope="scope">
								<el-button type="text" size="small" @click="gotoBatch(scope.row)">{{scope.row.name}}</el-button>
							</template>
						</el-table-column>
						<el-table-column
								prop="nums"
								align="center"
								header-align="left"
								label="待入库指标数（个）">
						</el-table-column>
						<el-table-column
								prop="staffCode"
								align="center"
								header-align="left"
								label="提交人">
						</el-table-column>
						<el-table-column
								prop="date"
								align="center"
								header-align="left"
								label="提交时间">
						</el-table-column>
					</el-table>
					<div class="pagination-wrapper">
						<el-pagination
								@current-change="getTableData"
								:current-page.sync="paginationData.currentPage"
								:page-size="paginationData.pageSize"
								layout="prev, pager, next, jumper"
								:total="paginationData.total">
						</el-pagination>
					</div>
				</template>
				<template v-else>
					<table-data-fail type="empty"></table-data-fail>
				</template>
			</div>
		</sidebar>
	</div>
</template>

<script>
	import sidebar from 'components/layout/sidebar.vue'
	import card from 'components/layout/card.vue'
	import tableDataFail from 'components/layout/tableDataFail.vue'
    import ajax from 'common/ajax.js'
    import ajaxUrls from 'common/ajaxUrls.js'
	export default{
		data(){
			return{
				loading: false,
				paginationData:{
					currentPage: 1,
					pageSize: 10,
					total: 0
				},
				tableDataError: false,
				tableData: []
			}
		},
        mounted(){
            this.getTableData();
        },
		methods: {
            gotoBatch(data){
                location.href = '/storageBatch.html?batchNo='+data.batchNo+'&id='+data.id;
			},
            getTableData(){
                let data = {
                    pageNum: this.paginationData.currentPage,
                    pageRow: this.paginationData.pageSize
                };
                data = Object.assign(data, this.queryData);
                ajax({
                    method: 'post',
                    url: ajaxUrls.apiUrl.FileConfig,
                    action: 'qryAuditFileConfig',
                    data: data
                }).then(function (data) {
                    this.tableData = data.data.items || [];
                    this.paginationData.total = data.data.totalNum || 0;
                }.bind(this)).catch(function (err) {

                })
            },
		},
		components:{
			sidebar,
			card,
			tableDataFail
		}
	}
</script>

<style lang="scss">
	.text-title{
		padding: 10px;
		font-size: 14px;
	}
</style>